<style type="text/css">
a {
	color: #F00;
	text-decoration: none
}
a:hover {
	color: #F60;
	text-decoration: underline
}
#authenticate {
	height: 160px;
	width: 500px;
	text-align: center;
	line-height: 25px;
	border: 1px solid #666;
}
#form1 table tr td #fileField {
	border: 1px solid #999;
	padding: 3px;
}
</style>
<script>
<?php
if($close){
?>
parent.location.reload(true);
<?php
}
?>
function check(){
	var cartCoin = <?=(int)Yii::app()->shoppingCart->getDiscountCoin()?>;
	var userCoin = <?=(int)$user->coin?>;
	var coin = document.getElementById('coin');
	var r = /^\d+$/　　//正整数    

	if(!r.test(coin.value)){
		alert('請輸入數字！');
		coin.focus();
		return false;
	}
	if(coin.value>userCoin){
		alert('輸入值大於您的餘額，請重新輸入！');
		coin.focus();
		return false;
	}
	if(coin.value>cartCoin){
		alert('輸入值大於當前購物金使用上限，請重新輸入！');
		coin.focus();
		return false;
	}
	document.form1.submit();
}
</script>
<div id="authenticate">
	<div style="margin-top:10px; height:100px">
		<form action="" method="post" name="form1" id="form1" style="margin-top:10px;text-align:left">
			<table width="480" border="0" align="center" cellpadding="0" cellspacing="0">
				<tr height="50">
					<td align="center">
						當前交易使用購物金上限為: <?=Yii::app()->shoppingCart->getDiscountCoin()?>， 您的購物金餘額為: <?=$user->coin?>
					</td>
				</tr>
				<tr height="50">
					<td align="center"> 請輸入您要使用的購物金:
						<input type="text" name="coin" id="coin" value="<?=Yii::app()->session->get('coin')?>" />
						<input type="button" onclick="check()" name="button" id="button" value="確定" />
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>
